package upm.pb4agent.team3;

import jade.core.Agent;
import jade.wrapper.AgentContainer;
import jade.wrapper.AgentController;

/**
 * This agent has the following functionality: 
 * <ul>
 * <li> 
 * <li> 
 * </ul>
 * @author Team3, UPM
 */
public class AgPlatform3 extends Agent {

	private static final long serialVersionUID = 3570392251197898901L;
	
	/*private Codec codec = new SLCodec();
	private Ontology ontology = PB4AgentOntology.getInstance();*/

	protected void setup() {

		//getContentManager().registerLanguage(codec);
		//getContentManager().registerOntology(ontology);
		System.out.println(getLocalName() + ": enters the system");
				
		createAgentsPlatformTeam3();
		//-gui "AgPlatform3:upm.pb4agent.team3.AgPlatform3;  AgTeam3:upm.pb4agent.team3.AgTeam3"
	}

	public boolean createAgentsPlatformTeam3() {		
		try {
			AgentContainer agentContainer = getContainerController();
			AgentController agentController = null;
			
			//
			ReadConfiguration.getInstance(1);
			String propTmp = ReadConfiguration.getValue("start_gui");
			boolean startGui = true;
			if(propTmp != null){
				startGui = Boolean.parseBoolean(propTmp);					
			}
			
			
			if(startGui){
				agentController = agentContainer.createNewAgent(   Constant.NAME_LAB_DECOROSO_COM
																 , Constant.CLASS_LAB_DECOROSO_COM
																 , null);
				agentController.start();
			}
			
			agentController = agentContainer.createNewAgent(Constant.NAME_REGISTRATION_DESK, Constant.CLASS_REGISTRATION_DESK, null);
			agentController.start();

			agentController = agentContainer.createNewAgent(Constant.NAME_REFEREE, Constant.CLASS_REFEREE, null);
			agentController.start();

			/*agentController = agentContainer.createNewAgent(Constant.NAME_WATCHER, Constant.CLASS_WATCHER, null);
			agentController.start();*/
			
			return true;
		} catch (Exception e) {
			System.out.println(Constant.NAME_AG_PLATFORM_X + "-::- error: "+ e.toString());
			return false;
		}
	}

}